﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;

class getFolderLink
{
    public string getlinkUL(string folderlink)
    {
        string[] a;
        // string rturn = "";
        string link = "";
        if (folderlink.Contains("ul.to/f/") || folderlink.Contains("uploaded.net/f/"))
        {
            a = Regex.Split(folderlink, "/f/");
            a[1].Replace("/", "");
            link = "http://uploaded.net/list/" + a[1] + "/plain";
        }
        else if (folderlink.Contains("uploaded.net/folder/") || folderlink.Contains("ul.to/folder/"))
        {
            a = Regex.Split(folderlink, "/folder/");
            link = "http://uploaded.net/list/" + a[1] + "/plain";
        }
        Uri myUri = new Uri(link);
        HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri);
        myHttpWebRequest.UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4";
        HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
        var stream = myHttpWebResponse.GetResponseStream();
        var reader = new StreamReader(stream);
        var html = reader.ReadToEnd();
        myHttpWebResponse.Close();
        return html;
    }
}

